Tool Use Guide
Overview
The Tool Use feature allows agents to call external tools during training to enhance reasoning capabilities. ROLL uses the GEM environment definition for environment interfaces, and Tool Use utilizes the Tool Env Wrapper provided by GEM. Tools are extended based on the gem.tools.base_tool.BaseTool interface.
Core Components
- BaseTool Interface (
gem.tools.base_tool.BaseTool): The fundamental interface that all tools must inherit from - Tool Env Wrapper (
roll.pipeline.agentic.tools.tool_env_wrapper.ToolEnvWrapper): A wrapper that adds tool calling capabilities to environments - Tool Registration Mechanism (
roll/pipeline/agentic/tools/__init__.py): Unified management and registration of available tools
Default Supported Tool Types
Currently, ROLL supports three default tools:
PythonCodeTool
- Function: Execute Python code
- Purpose: Mathematical calculations, data processing, algorithm implementation, etc.
- Implementation location:
roll/pipeline/agentic/tools/python_code_tool.py
class PythonCodeTool(GEMPythonCodeTool):
def __init__(
self,
timeout: int = 5,
sandbox_type: str = "none",
keep_error_last_line: bool = False,
tool_instruction=None,
patterns=None,
):
pass
SearchTool
- Function: Search for external information
- Purpose: Q&A systems, knowledge retrieval, fact verification, etc.
- Implementation location:
gem.tools.search_tool.SearchTool
class SearchTool(BaseTool):
def __init__(self, num_workers=1, search_url=None, topk=3, timeout=TIMEOUT):
pass
McpTool
- Function: Model Context Protocol tool
- Purpose: Interact with external models or services
- Implementation location:
roll.pipeline.agentic.tools.mcp_tool.MCPTool
class MCPTool(BaseTool):
def __init__(self,
num_workers=1,
server_url: Optional[str] = None,
client: Optional[MCPClient] = None,
tool_names_subset: Optional[List[str]] = None,
custom_prompt: Optional[str] = None):
pass
Tool Registration and Custom Extensions
Tool registration is located in roll/pipeline/agentic/tools/__init__.py. Users can customize tool implementations as needed and register them using register_tools.